//
//  StrategyCell.m
//  SimpleHappy
//
//  Created by lanou on 15/11/23.
//  Copyright © 2015年 RockyFung. All rights reserved.
//

#import "StrategyCell.h"
#import "Define.h"
#import "UIImageView+WebCache.h"

@interface StrategyCell()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *viceTitleLabel;
@property (nonatomic, strong) UIView *blackView;
@property (nonatomic, strong) UIImageView *bgView;


@end


@implementation StrategyCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = NO;
        
        CGFloat width = KScreenWidth - 10;
        CGFloat height = width / 640 * 330;

//        self.frame.size.height
        // 添加背景图片
        self.bgView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, width, height )];
        self.bgView.image= [UIImage imageNamed:@"placeholder@2x.png"];
        [self.contentView addSubview:_bgView];
        
        // 添加黑色半透明效果
        self.blackView = [[UIView alloc]initWithFrame:_bgView.frame];
        self.blackView.backgroundColor = [UIColor blackColor];
        self.blackView.alpha = 0.3;
         [self.contentView addSubview:_blackView];
        
        // 添加label
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, height/2.8, width, height/7)];
        self.titleLabel.text = @"";
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont boldSystemFontOfSize:KScreenWidth / 18.75];
        self.titleLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_titleLabel];
        
        self.viceTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, height/1.7, width, height/8)];
        self.viceTitleLabel.text = @"";
        self.viceTitleLabel.textAlignment = NSTextAlignmentCenter;
        self.viceTitleLabel.font = [UIFont systemFontOfSize:KScreenWidth / 22];
        self.viceTitleLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:_viceTitleLabel];
        
       
        
    }
    return self;
}

- (void)setModel:(StrategyModel *)model
{
    _model = model;
    // 设置背景图片
    [self.bgView sd_setImageWithURL:[NSURL URLWithString:model.picUrl]];
    // 设置标题
    self.titleLabel.text = [NSString stringWithFormat:@"- %@ -",model.title] ;
    // 设置副标题
    self.viceTitleLabel.text = model.viceTitle;
}

@end
